package jobflow.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity(name = "Calisan")
@Table(name="CALISAN")
public class Calisan implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Long id;
	private String ad;
	private String soyad;
	private Long yas;
	private Long cinsiyeti;
	private String egitim;	
	private List<Adres> adresList = new ArrayList<Adres>();
	//private Adres adres = new Adres();
	private List<Departman> departmanList  = new ArrayList<Departman>();	
	
	@Id
	@GeneratedValue
	@Column(name="ID")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
    @Column(name="AD")
	public String getAd() {
		return ad;
	}

	public void setAd(String ad) {
		this.ad = ad;
	}
    @Column(name="SOYAD") 
	public String getSoyad() {
		return soyad;
	}

	public void setSoyad(String soyad) {
		this.soyad = soyad;
	}
    @Column(name="YAS")
	public Long getYas() {
		return yas;
	}

	public void setYas(Long yas) {
		this.yas = yas;
	}
    @Column(name="CINSIYET")
	public Long getCinsiyeti() {
		return cinsiyeti;
	}
    
	public void setCinsiyeti(Long cinsiyeti) {
		this.cinsiyeti = cinsiyeti;
	}
    
	public void setEgitim(String egitim) {
		this.egitim = egitim;
	}
	@Column(name="EGITIM")
	public String getEgitim() {
		return egitim;
	}

//	public void setAdres(Adres adres) {
//		this.adres = adres;
//	}
//	
//	@ManyToOne(cascade=CascadeType.PERSIST,fetch=FetchType.LAZY)
//	@JoinColumn(name="ADRES_ID",nullable = false)
//	public Adres getAdres() {
//	
//		return adres;
//	}

	public void setAdresList(List<Adres> adresList) {
		this.adresList = adresList;
	}
    @OneToMany(mappedBy="calisan",cascade=CascadeType.ALL)
	public List<Adres> getAdresList() {
		return adresList;
	}

	public void setDepartmanList(List<Departman> departmanList) {
		this.departmanList = departmanList;
	}
	
    @ManyToMany
    @JoinTable(
    	      name="DEPARTMAN_CALISAN",
    	      joinColumns={@JoinColumn(name="CALISAN_ID", referencedColumnName="ID")},
    	      inverseJoinColumns={@JoinColumn(name="DEPARTMAN_ID", referencedColumnName="ID")})
	public List<Departman> getDepartmanList() {
		return departmanList;
	}

	

	
	

}
